package com.znow.admin.system.security.controller;

import com.znow.admin.system.security.model.dto.PermissionsTreeDTO;
import com.znow.admin.system.security.model.res.PermissionPageRequest;
import com.znow.admin.system.security.model.res.PermissionRequest;
import com.znow.admin.system.security.model.vo.component.ComponentVO;
import com.znow.admin.system.security.service.SysPermissionsService;
import com.znow.admin.system.security.util.SecurityUtils;
import com.znow.common.model.CommonResult;
import com.znow.common.model.PageResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 权限相关接口
 *
 * @author Nemo
 * @date 2022/12/19
 */
@AllArgsConstructor
@Api(value = "permissions", tags = "权限资源接口")
@RequestMapping("/sys/permissions")
@RestController
public class PermissionController {

    private final SysPermissionsService sysPermissionsService;

    @ApiOperation("获取当前用户所拥有的权限")
    @PostMapping("/get")
    public CommonResult<List<PermissionsTreeDTO>> getTreePermission() {
        Long userId = SecurityUtils.getUserId();
        return CommonResult.success(sysPermissionsService.getPermissionsByUserId(userId));
    }


}
